﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace TongHopBCTuan2014
{
    public partial class HuyenThang : Form
    {
        public HuyenThang()
        {
            InitializeComponent();
        }

        private void labelX2_Click(object sender, EventArgs e)
        {

        }

        private void HuyenThang_Load(object sender, EventArgs e)
        {
            //------------load thang---------------------
            for(int i=1;i<12;i++)
                cbbMonth.Nodes.Add(new DevComponents.AdvTree.Node(i.ToString()));
            for(int i=2013;i<=DateTime.Now.Year;i++)
                cbbYear.Nodes.Add(new DevComponents.AdvTree.Node(i.ToString()));
        
            //--------------------set data for district-----------------
            dlieuhuyen dlhuyen = new dlieuhuyen();
            List<huyen> lhuyen = dlhuyen.listHuyen();
            MessageBox.Show(lhuyen.Count.ToString());
            cbbDistrict.DataSource = lhuyen;
            cbbDistrict.DisplayMember = "TenHuyen";
            cbbDistrict.ValueMember = "MaHuyen";



            //------------------------attach data to report
            //ReportParameter Param0 = new ReportParameter("fromDate", fromDate.ToString(dateFormat));

            //ReportParameter Param1 = new ReportParameter("toDate", toDate.ToString(dateFormat));

            //ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { Param0, Param1 });

           
            //DataTable dt = new DataTable();
            //dt.Columns.Add("Name");
            //dt.Columns.Add("ImageID");
            //dt.Rows.Add();
            //dt.Rows.Add();
            //dt.Rows.Add();
            //dt.Rows.Add();
            //dt.Rows[0]["ImageID"] = 1;
            //dt.Rows[1]["ImageID"] = 2;
            //dt.Rows[2]["ImageID"] = 3;
            //dt.Rows[3]["ImageID"] = 4;
            //dt.Rows[0]["Name"] = "AKLJUH-981";
            //dt.Rows[1]["Name"] = "AKLJUH-982";
            //dt.Rows[2]["Name"] = "AKLJUH-983";
            //dt.Rows[3]["Name"] = "AKLJUH-984";
            //dt.Rows[0]["City"] = "Amritsar";
            //dt.Rows[1]["City"] = "Chandigarh";
            //dt.Rows[2]["City"] = "Saharanpur";
            //dt.Rows[3]["City"] = "YamunaNagar";

            //reportViewer1.Reset();
            //reportViewer1.LocalReport.DataSources.Clear();
            //ReportDataSource reportDSDetail = new ReportDataSource("DataSet1", dt);
            //reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
            //reportViewer1.LocalReport.DataSources.Add(reportDSDetail);
            //reportViewer1.LocalReport.EnableExternalImages = true;
            //reportViewer1.RefreshReport();
            //reportViewer1.Visible = true;
            //this.reportViewer1.RefreshReport();

            DataSet dsMonthly1 = new dsMonthly();
            DataRow dr;
            List<coupleData> lCoupleData=new List<coupleData>();
            for (int i = lCoupleData.Count - 1; i >= 0; i--)
            {
                dr = dsMonthly1.Tables[0].NewRow();
                dr["Conttent"] = lCoupleData[i].Content;
                dr["Order"] = lCoupleData[i].Order;
                dr["Sum"] = lCoupleData[i].Sum;
                dsMonthly1.Tables[0].Rows.Add(dr);

            }
            //for (int i = 0; i < 10; i++)
            //{
            //    dr = dsMonthly1.Tables[0].NewRow();
            //    dr["Conttent"] = i.ToString();
            //    dr["Order"] = i.ToString();
            //    dr["Sum"] = i.ToString();


            //    
            //}
            

            //ReportParameter Param0 = new ReportParameter("TENHUYEN", "11");
            //ReportParameter Param1 = new ReportParameter("sodonvi", "11");
            //ReportParameter Param2 = new ReportParameter("tungay", DateTime.Now.ToShortDateString());
            //ReportParameter Param3 = new ReportParameter("denngay", DateTime.Now.ToShortDateString());

            //rpMonthly.LocalReport.SetParameters(new ReportParameter[] { Param1, Param2, Param3 });

            rpMonthly.LocalReport.ReportEmbeddedResource = "TongHopBCTuan2014.forMonth.rdlc";
            ReportDataSource rds = new ReportDataSource();
            rds.Name = "dsMonthly_datainreport";
            rds.Value = dsMonthly1.Tables[0];
            rpMonthly.LocalReport.DataSources.Add(rds);



            this.rpMonthly.RefreshReport();


            // rpMonthly.LocalReport.DataSources.Add(reportDSDetail);
            //reportViewer1.LocalReport.EnableExternalImages = true;
            //reportViewer1.RefreshReport();
            //reportViewer1.Visible = true;
            //this.reportViewer1.RefreshReport();

            //this.rpMonthly.RefreshReport();
        }

        private void printPreviewDialog1_Load(object sender, EventArgs e)
        {

        }

        private void datainreportBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }
    }
}
